import javafx.print.Collation;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class O58II {
    public static void main(String[] args) {

    }
    public String reverseWords(String s) {

        List<String> list = new ArrayList<>();
        Scanner sc = new Scanner(s);
        while (sc.hasNext()){
            list.add(sc.next());
        }
        Collections.reverse(list);
        StringBuilder sb = new StringBuilder();
        for (String s1 : list) {
            sb.append(s1).append(" ");
        }
        String str = sb.toString();
        if (str.length()==0)
            return "";
        return str.substring(0,str.length()-1);
    }
}
